package pt.compflow.interfaces;

import java.util.ArrayList;
import java.util.List;

public abstract class IOInterfaceBase implements IOInterface {
	
	protected String interfaceClassUri;
	protected String interfaceUri;
	protected List<InterfaceListener> listeners;

	public IOInterfaceBase() {
	}
	
	public IOInterfaceBase(IOInterfaceBase interfaze) {
		this.interfaceClassUri = interfaze.interfaceClassUri;
		this.interfaceUri = interfaze.interfaceUri;
		this.listeners = interfaze.listeners;
	}

	public IOInterfaceBase(String interfaceUri, String interfaceClassUri) {
		this.interfaceUri = interfaceUri;
		this.interfaceClassUri = interfaceClassUri;
	}

	public String getInterfaceClassUri() {
		return interfaceClassUri;
	}

	public void setInterfaceClassUri(String interfaceClassUri) {
		this.interfaceClassUri = interfaceClassUri;
	}

	public String getInterfaceUri() {
		return interfaceUri;
	}

	public void setInterfaceUri(String interfaceUri) {
		this.interfaceUri = interfaceUri;
	}

	@Override
	public boolean addInterfaceListener(InterfaceListener l) {
		if (l == null)
			return false;
		if (listeners == null)
			listeners = new ArrayList<InterfaceListener>();
		if (!listeners.contains(l))
			listeners.add(l);
		return true;
	}

	@Override
	public boolean removeInterfaceListener(InterfaceListener l) {
		if (listeners == null || l == null)
			return false;
		return listeners.remove(l);
	}
	
	@Override
	public void setInterfaceListeners(List<InterfaceListener> listeners) {
		this.listeners = listeners;		
	}

}
